package com.fanshuai.config;

import io.fabric8.kubernetes.client.Config;
import io.fabric8.kubernetes.client.ConfigBuilder;
import io.fabric8.kubernetes.client.DefaultKubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClient;

import java.io.IOException;

public class KubernetesConfig {
    public static KubernetesClient client;
    public static KubernetesClient client2;

    //k8s mac desktop api server addr
    public static String url1 = "https://localhost:6443";
    //minikube k8s cluster api server addr
    public static String url2 = "https://127.0.0.1:55001/";

    //k8s mac desktop config file
    public static String k8s = "" +
            "apiVersion: v1\n" +
            "clusters:\n" +
            "\n" +
            "- cluster:\n" +
            "    certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM1ekNDQWMrZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRJeE1EWXhOVEE1TVRNeE9Wb1hEVE14TURZeE16QTVNVE14T1Zvd0ZURVRNQkVHQTFVRQpBeE1LYTNWaVpYSnVaWFJsY3pDQ0FTSXdEUVlKS29aSWh2Y05BUUVCQlFBRGdnRVBBRENDQVFvQ2dnRUJBT0xMCmMrYVduTk9XcWhqYm43YnMzTlo4dCtnY1B3WWVDeG02eWRINnl5U1ppUU9TSU81TGtIeFhBMmltYm9kU0pxcDgKckNmVFJtK3ZlTEhReTVsc2lJdWF0ekNDaUxteGo1M2YwWjRTdlNEc2RwODl4RGJGSjJrNUFQelRoMjR6MnZTKwpSQ1pObkJWUmxCdFA0bXI4N2cweGR6U0RwZnZuME1HR3AzZW52S1IvMWtRQ0IzNi84Z081eFlGbUo3K2hacEJtCmYzWTJVa24rNmc0Wm5iOUcyNU5WVUhlOEIxaFBxMXNyblVrczlKcnJJQ28vLzBtL21LaFBORXI2OGVSb3gxUVEKYTBFeStpOGsvWWdadUlldm1UNEpPZTg2TzRraHVVZVpnVHZzUGtTcGpwRGZQSXRzZmNNYUc0VUxvdkRjMHV3ZQpSa1JUVXIwaFlCbEJuYkJEalZFQ0F3RUFBYU5DTUVBd0RnWURWUjBQQVFIL0JBUURBZ0trTUE4R0ExVWRFd0VCCi93UUZNQU1CQWY4d0hRWURWUjBPQkJZRUZKSUp3UjBMNytVc2NiK0dNQ1RDem93UEhkTmFNQTBHQ1NxR1NJYjMKRFFFQkN3VUFBNElCQVFCZXpQQml0dER5clRuYW5HS0NNYkp2Q0pxMmJkUWlGaFF0NjQ2TVJ0bW9idk15em9PUwpobkFVM01vYS9uQ1NjV1hrbDZDNlE5aTU2aHFsSGRTZkpOcXFDeGgxRVVTdHM5WHlwU0dSZ0pJVlJmSU16YkpjCm4zSjF2Sk11b2FYL3BwU0tHTGc1bi9wZ1Q2a2F0T1Z3WlM0cll0TlY5YUFiUWFmVmNtUFdMbkYyVytHYVY1WjEKNTBSSHdVL3BCeGk2My9sNmRya3BFZTZ1dFJGQ09EdVoyemVlQlZNbWpyc24vMk5TTms2ZG1ZOXJUWTNHK3RPRwpHQnc2Vm1VY3MwcGxXTjhPMlpTeEFNdSswWThvVTZWZEdvWTYyU2loM3VrYUdNNHNlN05jVnB2TmtZN2tIS3ZvCmdLcUtKS2ZQQmkvU25iWUxLazQ0U2szTjVqMUxZanIyT281SAotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==\n" +
            "    server: https://kubernetes.docker.internal:6443\n" +
            "  name: docker-desktop\n" +
            "\n" +
            "contexts:\n" +
            "- context:\n" +
            "    cluster: docker-desktop\n" +
            "    user: docker-desktop\n" +
            "  name: docker-desktop\n" +
            "\n" +
            "current-context: docker-desktop\n" +
            "kind: Config\n" +
            "preferences: {}\n" +
            "users:\n" +
            "- name: docker-desktop\n" +
            "  user:\n" +
            "    client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURGVENDQWYyZ0F3SUJBZ0lJRzhNVEN2bUtOSGd3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWE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XMreS9ONjBkUUtRTmxPQ00zNU0weGdmbVFQdmVZd1I0MHRyYUxvNnYvSmRYdGR1TGlYVEI0R1lOUHZ3VXZGSQoyS2RxOG14M0NzQ09DQWE3TWszU3BRTVo5dHN6a3VWdkI3dndiN2NmMGJFVlUwTy9BUXJMeTV0TktjbEI2THE3Ckp6VkpBb0dCQUsxTkFKc09uOFVqeURxeDMyaXZoVUlSeE1DTXdMVzBYOE1HSjVPS1d5TEdYcHBWcGV6b0lEWDgKSGpWczhvTEFablR3cTZQa1BVVjhxc3gvZ0tZR0tuSFBjNzE3STNjQ1FXWVFnRm9HeTVJaVpOVzNUZ3lPYmpQTwpibVR5Y0svTFNiVDRuQWV5RmRvZEhLMmJ6Zi9tK2xWdGtPKy9POG0yNG40V2NGUWl1SXJICi0tLS0tRU5EIFJTQSBQUklWQVRFIEtFWS0tLS0tCg==";

    public static String k8s2 = "" +
            "apiVersion: v1\n" +
            "clusters:\n" +
            "- cluster:\n" +
            "    certificate-authority: /Users/myselffan/.minikube/ca.crt\n" +
            "    server: https://127.0.0.1:55001\n" +
            "  name: minikube\n" +
            "contexts:\n" +
            "- context:\n" +
            "    cluster: minikube\n" +
            "    extensions:\n" +
            "    namespace: default\n" +
            "    user: minikube\n" +
            "  name: minikube\n" +
            "current-context: minikube\n" +
            "kind: Config\n" +
            "preferences: {}\n" +
            "users:\n" +
            "- name: minikube\n" +
            "  user:\n" +
            "    client-certificate: /Users/myselffan/.minikube/profiles/minikube/client.crt\n" +
            "    client-key: /Users/myselffan/.minikube/profiles/minikube/client.key";

    static {
        try {
            Config config = Config.fromKubeconfig(k8s);
            client = new DefaultKubernetesClient(config);

            Config config2 = Config.fromKubeconfig(k8s2);
            //client2 = new DefaultKubernetesClient(config2);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
